package com.cskaoyan.controller;

import com.cskaoyan.bean.VO.AdminConfigExpressVo;
import com.cskaoyan.bean.VO.AdminConfigMallVo;
import com.cskaoyan.bean.VO.AdminConfigOrderVo;
import com.cskaoyan.bean.VO.AdminConfigWxVo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.service.AdminConfigService;
import com.cskaoyan.service.AdminOrderService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:配置管理模块
 * @author:刘杰
 * @create: 2022-08-14 22:37
 */
@RestController
@RequestMapping("admin/config")
public class AdminConfigController {

    @Autowired
    AdminConfigService adminConfigService;

    /**
     * 商场配置页面数据显示
     * @return
     */
    @RequiresPermissions("admin:config:mall:list")
    @GetMapping("mall")
    public BaseRespVo mall(){
        AdminConfigMallVo adminConfigMallVo = adminConfigService.mall();
        return BaseRespVo.ok(adminConfigMallVo);
    }

    /**
     * 修改商场配置页面数据
     * @param adminConfigMallVo
     * @return
     */
    @RequiresPermissions("admin:config:mall:updateConfigs")
    @PostMapping("mall")
    public BaseRespVo mall(@RequestBody AdminConfigMallVo adminConfigMallVo){
        adminConfigService.updatemall(adminConfigMallVo);
        return BaseRespVo.ok("成功");
    }

    /**
     * 运费配置页面数据显示
     * @return
     */
    @RequiresPermissions("admin:config:express:list")
    @GetMapping("express")
    public BaseRespVo express(){
        AdminConfigExpressVo expressVo = adminConfigService.express();
        return BaseRespVo.ok(expressVo);
    }

    /**
     * 运费配置页面数据修改
     * @param adminConfigExpressVod
     * @return
     */
    @RequiresPermissions("admin:config:express:updateConfigs")
    @PostMapping("express")
    public BaseRespVo updateexpress(@RequestBody AdminConfigExpressVo adminConfigExpressVod){
        adminConfigService.updateexpress(adminConfigExpressVod);
        return BaseRespVo.ok("成功");
    }

    @RequiresPermissions("admin:config:order:list")
    @GetMapping("order")
    public BaseRespVo order(){
        AdminConfigOrderVo adminConfigOrderVo = adminConfigService.order();
        return BaseRespVo.ok(0,adminConfigOrderVo,"成功");
    }

    @RequiresPermissions("admin:config:order:updateConfigs")
    @PostMapping("order")
    public BaseRespVo orderUpdate(@RequestBody AdminConfigOrderVo adminConfigOrderVo){
        adminConfigService.updateOrder(adminConfigOrderVo);
        return BaseRespVo.ok("成功");
    }

    @RequiresPermissions("admin:config:wx:list")
    @GetMapping("wx")
    public BaseRespVo wx(){
        AdminConfigWxVo adminConfigWxVo = adminConfigService.wx();
        return BaseRespVo.ok(0,adminConfigWxVo,"成功");
    }

    @RequiresPermissions("admin:config:wx:updateConfigs")
    @PostMapping("wx")
    public BaseRespVo wxUpdate(@RequestBody AdminConfigWxVo adminConfigWxVo){
        adminConfigService.updateWx(adminConfigWxVo);
        return BaseRespVo.ok("成功");
    }
}
